package com.rw.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class Test2Controller {

    @RequestMapping("resp")
    public void testResp(String name,Integer age,HttpServletResponse response) throws IOException {
        System.out.println("Test2Controller.testResp"+"testResp执行了,name="+name+":age="+age);
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().println("这儿是testResp的页面");
    }

    @RequestMapping("tforward")
    public String testForward(String name){
        System.out.println("Test2Controller.testForward执行了---"+name);
        return "test.jsp";
    }

    @RequestMapping("test2")
    public void testForward2(String name,HttpServletResponse response) throws IOException {
        System.out.println("转发后的方法---"+name);
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().println("这儿是转发后的一个页面");
    }

    @RequestMapping("tredirect")
    public String testRedirect(){
        System.out.println("转发方法执行---");
    return "redirect:/test2";
    }
}
